/*
 * Region.h
 *
 *  Created on: 23.07.2011
 *      Author: seb
 */

#ifndef REGION_H_
#define REGION_H_

#define JOIN_DISTANCE 100
#define LEAVE_DISTANCE 200

class IMapGenerator;
class Entity;
class Player;

/**
 * The game world is divided into regions, each of which is managed by a different peer.
 * This class represents such a region.
 */
class Region {
public:
	Region(int regionX, int regionY);
	virtual ~Region();

	/**
	 * @return a two dimensional array of Entities that represent the map/topology of this region
	 */
	virtual Entity*** getMap();

	/**
	 * @return the x coordinate of this region
	 */
	virtual int getX();
	/**
	 * @return the y coordinate of this region
	 */
	virtual int getY();

	/**
	 * @see JOIN_DISTANCE
	 * @param player the Player for which to check if he is within distance
	 * @return true if the region should be joined, false otherwise
	 */
	virtual bool isWithinJoiningDistance(Player* player);
	/**
	 * @see LEAVE_DISTANCE
	 * @param player the Player for which to check if he is within distance
	 * @return true if the region should be leaved, false otherwise
	 */
	virtual bool isWithinLeavingDistance(Player* player);

private:
	/**
	 * @param px the point x coordinate
	 * @param py the point y coordinate
	 * @return the distance between the given point and this region
	 */
	virtual float distanceToPoint(float px, float py);

	Entity*** map;
	int x, y;
};

#endif /* REGION_H_ */
